package com.lyz.ejb.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityResult;
import javax.persistence.FieldResult;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;
import javax.persistence.SqlResultSetMappings;
import javax.persistence.Table;

/**
 * Party entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@NamedNativeQuery(
		name="testParty",
		query="select p.party_id,p.party_type_id,pg.group_name  from party p,party_group pg " +
			"where p.party_id = pg.party_id and p.party_id = :orgId ",
		resultSetMapping="testOrganizationSqlResultMapping"
	)
@SqlResultSetMappings({	
	@SqlResultSetMapping(name="testOrganizationSqlResultMapping", 
		entities={
			@EntityResult(
		    	entityClass=com.lyz.ejb.entity.Party.class
		    ),
		    @EntityResult(
		    	entityClass=com.lyz.ejb.entity.PartyGroup.class
		    	,
		    	fields={
		    		@FieldResult(name="partyId", column="party_id"),
		    		@FieldResult(name="groupName", column="group_name"),
		    		@FieldResult(name="comments", column="comments"),
		    		@FieldResult(name="federalTaxId", column="federal_tax_id")
		    	}
		    	
		    )
		    
		}
	),
	@SqlResultSetMapping(name="testorg", 
		entities={
		    @EntityResult(
		    	entityClass=com.lyz.ejb.entity.PartyGroup.class
		    	,
		    	fields={
		    		@FieldResult(name="partyId", column="pgid"),
		    		@FieldResult(name="groupName", column="group_name"),
		    		@FieldResult(name="federalTaxId", column="federal_tax_id")
		    	}
		    	
		    )
		    
		}
	)
})
@Table(name = "PARTY", uniqueConstraints = {})
public class Party implements java.io.Serializable {

	// Fields

	private String partyId;
	private String partyTypeId;

	// Constructors

	/** default constructor */
	public Party() {
	}

	/** minimal constructor */
	public Party(String partyId) {
		this.partyId = partyId;
	}

	/** full constructor */
	public Party(String partyId, String partyTypeId) {
		this.partyId = partyId;
		this.partyTypeId = partyTypeId;
	}

	// Property accessors
	@Id
	@Column(name = "PARTY_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 40)
	public String getPartyId() {
		return this.partyId;
	}

	public void setPartyId(String partyId) {
		this.partyId = partyId;
	}

	@Column(name = "PARTY_TYPE_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 40)
	public String getPartyTypeId() {
		return this.partyTypeId;
	}

	public void setPartyTypeId(String partyTypeId) {
		this.partyTypeId = partyTypeId;
	}

}